package cn.edu.javaweb.userServlet;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.javaweb.utils.DBUtil;

@WebServlet("/RecruitDetailServlet")
public class RecruitDetailServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	DBUtil db;
        
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//设置编码方式
	    request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");   //不设置会乱码
				
		//从UserHome.jsp中获取参数
		String id=request.getParameter("id");
		System.out.println(id);
		
		db = new DBUtil();
		List<Map<String, String>> list = db.getList("select * from notice where id="+id+"");
		request.setAttribute("details", list);
		System.out.println(list);
		
		response.setContentType("text/html;charset=utf-8");
		RequestDispatcher rd=request.getRequestDispatcher("volunteer/user/RecruitDetail.jsp");
	    rd.forward(request, response);		
	}
}
